package com.xfcy.blog.utils;

import cn.dev33.satoken.secure.BCrypt;

/**
 * @author 晓风残月Lx
 * @date 2023/4/21 8:33
 */
public class BCryptUtils {

    /**
     * 加密
     * @param plainPassword
     * @return
     */
    public static String encrypt(String plainPassword) {
       return BCrypt.hashpw(plainPassword, BCrypt.gensalt());
    }

    /**
     * 检验密码和加密后的密码是否相同
     * @param plainPassword
     * @param encryptedPassword
     * @return
     */
    public static boolean checkPassword(String plainPassword, String encryptedPassword) {
        return BCrypt.checkpw(plainPassword, encryptedPassword);
    }

}
